﻿using MB.Orm.DB;
using MB.RuleBase.Common;
using Model;
using Public.DataAccess;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Business.Service
{
    public class BFileManage
    {
        public BFileManage() { }

        /// <summary>
        /// 根据系统ID查询系统文件夹名称
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="total"></param>
        /// <param name="parValues"></param>
        /// <returns></returns>
        public List<OAFileManage> GetOAFileManageInfo(int pageIndex, int pageSize, out int total, params object[] parValues)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<OAFileManage> list = PagedDatabaseExcuteByXmlHelper.NewInstance.GetPagedObjectsByXml3<OAFileManage>
                                                ("OAFileManage", "GetOAFileManageInfo", pageIndex, pageSize, out total, parValues);
                return list;
            }
        }


        /// <summary>
        /// 根据条件查询文件系统信息
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="total"></param>
        /// <param name="parValues"></param>
        /// <returns></returns>
        public List<OAFileSystem> GetFileSystemAllInfo(int pageIndex, int pageSize, out int total, params object[] parValues)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<OAFileSystem> list = PagedDatabaseExcuteByXmlHelper.NewInstance.GetPagedObjectsByXml3<OAFileSystem>
                                                ("OAFileManage", "GetFileSystem", pageIndex, pageSize, out total, parValues);
                return list;
            }
        }

        /// <summary>
        /// 根据条件查询文件系统信息
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="total"></param>
        /// <param name="parValues"></param>
        /// <returns></returns>
        public List<OAFileManage> GetFileModularAllInfo(int pageIndex, int pageSize, out int total, params object[] parValues)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<OAFileManage> list = PagedDatabaseExcuteByXmlHelper.NewInstance.GetPagedObjectsByXml3<OAFileManage>
                                                ("OAFileManage", "GetFileModular", pageIndex, pageSize, out total, parValues);
                return list;
            }
        }
        /// <summary>
        /// 根据系统ID查询系统文件夹名称
        /// </summary>
        /// <param name="systemID"></param>
        /// <returns></returns>
        public List<OAFileSystem> GetFileSystemInfo(int systemID)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<OAFileSystem> oAFileSystem = DatabaseExcuteByXmlHelper.NewInstance.GetObjectsByXml<OAFileSystem>("OAFileManage", "GetFileSystemInfo", systemID);
                return oAFileSystem;
            }
        }

        /// <summary>
        /// 根据模块名称查询模块文件夹名称
        /// </summary>
        /// <param name="modularID"></param>
        /// <returns></returns>
        public List<OAFileModular> GetFileModularInfo(int modularID)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<OAFileModular> oAFileModular = DatabaseExcuteByXmlHelper.NewInstance.GetObjectsByXml<OAFileModular>("OAFileManage", "GetFileModularInfo", modularID);
                return oAFileModular;
            }
        }


        /// <summary>
        /// 获取全部模块
        /// </summary>
        /// <param name="seedType"></param>
        /// <returns></returns>
        public List<OAFileModular> GetFileModularInfoByDropDownList(string defaultValue)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<OAFileModular> lmSeedlist = DatabaseExcuteByXmlHelper.NewInstance.GetObjectsByXml<OAFileModular>("OAFileManage", "GetFileModularALLInfo");
                if (defaultValue != null && defaultValue != "")
                {
                    lmSeedlist.Add(new OAFileModular() { MODULARID = 0, MODULARNAME = defaultValue });

                }
                return lmSeedlist;
            }
        }

        /// <summary>
        /// 获取全部系统
        /// </summary>
        /// <param name="seedType"></param>
        /// <returns></returns>
        public List<OAFileSystem> GetFileSystemInfoByDropDownList(string defaultValue)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<OAFileSystem> lmSeedlist = DatabaseExcuteByXmlHelper.NewInstance.GetObjectsByXml<OAFileSystem>("OAFileManage", "GetFileSystemALLInfo");
                if (defaultValue != null && defaultValue != "")
                {
                    lmSeedlist.Add(new OAFileSystem() { SYSTEMID = 0, SYSTEMNAME = defaultValue });

                }
                return lmSeedlist;
            }
        }

        /// <summary>
        /// 新增上传文件信息
        /// </summary>
        /// <param name="oAFileManage"></param>
        /// <returns></returns>
        public int InsertOAFileManage(OAFileManage oAFileManage)
        {
            return DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQueryByEntity<OAFileManage>("OAFileManage", "InsertOAFILEMANAGE", oAFileManage);
        }


        /// <summary>
        /// 新增系统信息
        /// </summary>
        /// <param name="oAFileManage"></param>
        /// <returns></returns>
        public int InsertOASystem(OAFileSystem oAFileSystem)
        {
            return DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQueryByEntity<OAFileSystem>("OAFileManage", "InsertOASystem", oAFileSystem);
        }

        /// <summary>
        /// 新增模块信息
        /// </summary>
        /// <param name="oAFileManage"></param>
        /// <returns></returns>
        public int InsertFileModular(OAFileModular oAFileModular)
        {
            return DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQueryByEntity<OAFileModular>("OAFileManage", "InsertFileModular", oAFileModular);
        }
    }
}
